package com.redxun.model.response;

import lombok.*;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@ToString
@Builder
public class BaseResponse<T> implements Serializable {


    private static final long serialVersionUID = -7117799888786866678L;

    private Boolean success;
    private Boolean licenseSuccess;
    private String message;
    private String detailMsg;
    private Boolean show;
    private String status;
    private Integer code;
    private Object data;
    private T result;

    public static <T> BaseResponse<T> success() {
        return BaseResponse.<T>builder().success(true).licenseSuccess(true).show(false).status("success")
                .code(200).message("成功").build();
    }

    public static <T> BaseResponse<T> success(T data) {
        return BaseResponse.<T>builder().success(true).licenseSuccess(true).show(false).status("success")
                .code(200).message("成功").result(data).build();
    }

    public static <T> BaseResponse<T> fail(String message) {
        return BaseResponse.<T>builder().success(false).licenseSuccess(false).show(true).status("fail")
                .code(400).message(message).result(null).build();
    }


}